#pragma once

#include <QWidget>
#include <QLabel>
#include <QPushButton>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include "util/serverhelper.h"

namespace Ui {
class PostCardWidget;
}

namespace WordMemory {

class PostCardWidget : public QWidget
{
    Q_OBJECT

public:
    explicit PostCardWidget(const CommunityPost &post, QWidget *parent = nullptr);
    ~PostCardWidget();

    void updateLikeState(int newLikesCount, bool isLikedByMe);
    void updateShareCount(int newSharesCount);


signals:
    void cardClicked(int postId);
    void likeClicked(int postId);
    void shareClicked(int postId);

protected:
    void mousePressEvent(QMouseEvent *event) override;

private:
    void setupUi();

    CommunityPost m_post;

    QLabel *titleLabel;
    QLabel *authorLabel;
    QLabel *previewLabel;
    QLabel *timeLabel;
    QPushButton *likeButton;
    QLabel *likesCountLabel;
    QPushButton *shareButton;
    QLabel *sharesCountLabel;
};

}
